import * as echarts from "echarts";

// 卡片数据
export const cardData = {
    leftConfig: {
        // 卡片样式
        cardStyle: {
            padding: "10px",
        },
        // 布局配置
        colLayout: {
            xl: 24,
            lg: 24,
            md: 24,
            sm: 24,
            xs: 24
        },
        data: [
            {
                cardId: 1,
                title: "舆情趋势分析",
                showSectionCondition: "download,enlarge",
                cardFilterOptions: [ // 卡片筛选项
                ],
                cardBodyConfig: {
                    type: "echart", // 类型 echart/table
                    url: "/cardBodyAddress1", // 接口地址
                    style: {
                        height: 220
                    }, // 卡片主体样式
                    config: {
                        tooltip: {
                            trigger: "axis",
                        },
                        legend: {
                            show: false
                        },
                        grid: {
                            left: '3%',
                            right: '10%',
                            top: "10%",
                            bottom: '5%',
                            containLabel: true
                        },
                        dataset: {
                            dimensions: ["label", "value"],
                            source: [
                                { label: '测试1', value: 1000 },
                                { label: '测试2', value: 888 },
                                { label: '测试3', value: 884 },
                                { label: '测试4', value: 600 },
                                { label: '测试5', value: 500 }
                            ]
                        },
                        dataZoom: [
                            {
                                show: true,
                                type: "inside",
                                endValue: 5,
                                xAxisIndex: [0, 1],  // 注意顺序，0 是主要的 xAxis
                            },
                        ],
                        xAxis: {
                            type: 'category',
                            axisLine: {
                                show: true,
                                lineStyle: {
                                    width: 1,
                                    color: "rgba(6,156,162,0.34)"
                                }
                            },
                            axisTick: {
                                show: false   // 隐藏 x 轴刻度线
                            },
                            axisLabel: {
                                color: '#BCCBCC',
                                fontSize: 10,
                                fontWeight: 400
                            },
                            splitLine: {
                                show: false
                            }
                        },
                        yAxis: {
                            type: 'value',
                            axisLine: {
                                show: false
                            },
                            axisTick: {
                                show: false   // y 轴刻度线默认显示，可省略
                            },
                            axisLabel: {
                                color: '#BCCBCC',
                                fontSize: 8,
                                fontWeight: 400
                            },
                            splitLine: {
                                show: true,  // 显示网格线
                                lineStyle: {
                                    color: "rgba(6,156,162,0.34)",  // 你可以调整颜色和透明度
                                    type: "solid"
                                }
                            }
                        },
                        series: [{
                            type: 'line',
                            symbol: 'circle',
                            symbolSize: 4,
                            lineStyle: {
                                color: '#FFF462',
                                width: 1
                            },
                            itemStyle: {
                                color: '#FFF462'
                            },
                            label: {
                                show: false,
                                position: 'top',
                                color: '#BBD2E9',
                                fontSize: 7,
                            },
                            encode: {
                                x: 'label',
                                y: 'value'
                            }
                        }]
                    }, // 卡片配置
                }
            },
            {
                cardId: 3,
                title: "热点预警明细",
                showSectionCondition: "",
                cardFilterOptions: [ // 卡片筛选项
                ],
                cardBodyConfig: {
                    type: "table", // 类型 echart/table
                    url: "/cardBodyAddressTable1", // 接口地址
                    style: {
                        height: 230
                    }, // 卡片主体样式
                    config: {
                        // 是否显示序号
                        showIndexColumn: true,
                        // 是否显示可选
                        showSelectColumn: false,
                        // 是否显示分页
                        showFooter: false,
                        // 表格数据
                        propsList: [
                            { prop: 'key1', label: '区域名称', align: 'left', width: "100px" },
                            { prop: 'key2', label: '饱和度', align: 'left', width: "120px" },
                            { prop: 'key3', label: '游客数', align: 'left', width: "120px" }
                        ],
                        // 表格配置项
                        tableAttrConfig: {
                            // 是否显示边框
                            border: true,
                            // 是否显示统计
                            showSummary: false,
                            headerCellStyle: {
                                background: 'rgba(18, 68, 87, 0.54)',
                                color: '#fff',
                                fontFamily: 'PingFang SC',
                                fontSize: '12px',
                                fontStyle: 'normal',
                                fontWeight: '400',
                                borderRadius: "3px",
                                // borderRight: "2px solid #091520",
                                // boxSizing: "border-box"
                            },
                            cellStyle: {
                                fontSize: "12px",
                                color: "#BCCBCC",
                                backgroundColor: 'transparent',
                            }
                        }
                    }, // 卡片配置
                }
            },
            {
                cardId: 1,
                title: "舆情传播分析",
                showSectionCondition: "download,enlarge",
                cardFilterOptions: [ // 卡片筛选项
                ],
                cardBodyConfig: {
                    type: "echart", // 类型 echart/table
                    url: "/cardBodyAddress1", // 接口地址
                    style: {
                        height: 220
                    }, // 卡片主体样式
                    config: {
                        tooltip: {
                            trigger: 'item',
                            triggerOn: 'mousemove'
                        },
                        series: [{
                            type: 'tree',
                            data: [{
                                "name": "XX医科XX第二医院",
                                "children": [{
                                    "name": "1~10名",
                                    collapsed: false,
                                    "children": [{
                                        "name": "呼吸内科",
                                        collapsed: false,
                                        "children": [{
                                            "name": "麻醉",
                                            "value": 3938
                                        },
                                        {
                                            "name": "护理",
                                            "value": 3812
                                        },

                                        ]
                                    },
                                    {
                                        "name": "内分泌科",
                                        collapsed: true,
                                        "children": [{
                                            "name": "麻醉",
                                            "value": 3938
                                        },
                                        {
                                            "name": "护理",
                                            "value": 3812
                                        },

                                        {
                                            "name": "其他",
                                            "value": 743
                                        },
                                        ]
                                    },
                                    {
                                        "name": "心内科",
                                        collapsed: true,
                                        "children": [{
                                            "name": "麻醉",
                                            "value": 3938
                                        },
                                        {
                                            "name": "护理",
                                            "value": 3812
                                        },

                                        ]
                                    },
                                    {
                                        "name": "骨科",
                                        collapsed: true,
                                        "children": [{
                                            "name": "麻醉",
                                            "value": 3938
                                        },
                                        {
                                            "name": "护理",
                                            "value": 3812
                                        },

                                        ]
                                    },
                                    {
                                        "name": "普外科",
                                        collapsed: true,
                                        "children": [{
                                            "name": "麻醉",
                                            "value": 3938
                                        },
                                        {
                                            "name": "护理",
                                            "value": 3812
                                        },

                                        ]
                                    },
                                    {
                                        "name": "神经外科",
                                        collapsed: true,
                                        "children": [{
                                            "name": "麻醉",
                                            "value": 3938
                                        },
                                        {
                                            "name": "护理",
                                            "value": 3812
                                        },
                                        {
                                            "name": "放射",
                                            "value": 6714
                                        },

                                        ]
                                    },
                                    {
                                        "name": "肿瘤科",
                                        collapsed: true,
                                        "children": [{
                                            "name": "麻醉",
                                            "value": 3938
                                        },
                                        {
                                            "name": "护理",
                                            "value": 3812
                                        },

                                        ]
                                    },
                                    ]
                                }
                                ]
                            }],
                            top: '1%',
                            left: '14%',
                            bottom: '1%',
                            right: '20%',
                            symbolSize: 14,
                            label: {
                                position: 'left',
                                verticalAlign: 'middle',
                                align: 'right',
                                fontSize: 14
                            },
                            leaves: {
                                label: {
                                    position: 'right',
                                    verticalAlign: 'middle',
                                    align: 'left'
                                }
                            },
                            emphasis: {
                                focus: 'descendant'
                            },
                            expandAndCollapse: true,
                            animationDuration: 550,
                            animationDurationUpdate: 750
                        }]
                    }, // 卡片配置
                }
            },
        ]
    },
    rightConfig: {
        // 卡片样式
        cardStyle: {
            padding: "10px",
        },
        // 布局配置
        colLayout: {
            span: 24
        },
        data: [
            {
                cardId: 2,
                title: "情绪分析",
                showSectionCondition: "download,enlarge",
                cardFilterOptions: [
                ],
                cardBodyConfig: {
                    type: "echart", // 类型 echart/table
                    url: "/cardBodyAddress2", // 接口地址
                    style: {
                        height: 220
                    }, // 卡片主体样式
                    config: {
                        tooltip: {
                            trigger: "item",
                        },
                        legend: {
                            orient: "vertical",
                            right: "15%",
                            top: "middle",
                            itemHeight: 6,
                            itemWidth: 7,
                            textStyle: {
                                fontSize: 8,
                                rich: {
                                    color0: { color: '#4E7CD8' },
                                    color1: { color: '#4EBC92' },
                                    color2: { color: '#FFAF3D' },
                                    color3: { color: '#FF5F12' }
                                }
                            },
                            formatter: (name) => {
                                const source = cardData.rightConfig.data[0].cardBodyConfig.config.dataset.source;
                                const index = source.findIndex(i => i.name === name);
                                const item = source[index];
                                if (item) {
                                    // 颜色样式名和索引对应
                                    const styleName = `color${index}`;
                                    return `{${styleName}|${name}  ${item.value}  ${item.percentage}%}`;
                                }
                                return name;
                            }
                        },
                        dataset: {
                            dimensions: ["name", "value", "percentage"],
                            source: [
                                { name: "测试1", value: 10, percentage: 10 },
                                { name: "测试2", value: 20, percentage: 20 },
                                { name: "测试3", value: 70, percentage: 70 },
                                { name: "测试4", value: 50, percentage: 50 },
                            ]
                        },
                        series: [
                            {
                                type: "pie",
                                encode: {
                                    itemName: "name",
                                    value: "value"
                                },
                                color: ['#4E7CD8', '#4EBC92', '#FFAF3D', '#FF5F12', '#C2DCD5', '#9D6B0A'],
                                center: ['25%', '50%'],
                                radius: ['45%', '65%'],
                                label: {
                                    show: false
                                }
                            }
                        ],
                    }, // 卡片配置
                }
            },
        ]
    }
}